# 建筑工地，执法任务
import time

from Lib.base.keywords import KeyWords
from selenium.webdriver.common.by import By
from Lib.common.common_function import *
from Lib.base.page_object.login_page import LonginPage
import uuid
import random


class Task(KeyWords):
    url = KeyWords.url + 'worksite/task'

    def create_task(self):
        '''
        新建建筑工地相关的执法任务
        :return:
        '''
        data = get_data_by_yaml(get_path() + r'\Data\element_data\site_manage\task\create_task.yaml')
        element_operation(self, data[0]['data'])

    def task_list_by_source(self):
        '''
        根据任务来源进行筛选
        :return:
        '''
        data = get_data_by_yaml(get_path() + r'\Data\element_data\site_manage\task\task_list_by_source.yaml')
        element_operation(self, data[0]['data'])

    def task_list_by_stage(self):
        '''
        根据任务阶段进行筛选
        :return:
        '''
        data = get_data_by_yaml(get_path() + r'\Data\element_data\site_manage\task\task_list_by_stage.yaml')
        element_operation(self, data[0]['data'])

    def task_list_by_status(self):
        '''
        根据任务状态进行筛选
        :return:
        '''
        data = get_data_by_yaml(get_path() + r'\Data\element_data\site_manage\task\task_list_by_status.yaml')
        element_operation(self, data[0]['data'])

    def task_list_sort(self):
        '''
        查看近7天的数据 以及按任务时间进行排序
        :return:
        '''
        data = get_data_by_yaml(get_path() + r'\Data\element_data\site_manage\task\task_list_sort.yaml')
        element_operation(self, data[0]['data'])

    def task_search_error(self):
        '''
        执法任务查询， 查询错误的值
        :return:
        '''
        data = get_data_by_yaml(get_path() + r'\Data\element_data\site_manage\task\task_search_error.yaml')
        element_operation(self, data[0]['data'])

    def task_search(self):
        '''
        搜索执法任务，正确的值和错误的值
        :return:
        '''
        data = get_data_by_yaml(get_path() + r'\Data\element_data\site_manage\task\task_search.yaml')
        element_operation(self, data[0]['data'])

    def task_detail_accept(self):
        '''
        查看执法任务详情并受理
        :return:
        '''
        data = get_data_by_yaml(get_path() + r'\Data\element_data\site_manage\task\task_detail_accept.yaml')
        element_operation(self, data[0]['data'])

    def task_detail_inspect(self):
        '''
        查看执法任务详情并检查
        :return:
        '''
        data = get_data_by_yaml(get_path() + r'\Data\element_data\site_manage\task\task_detail_inspect.yaml')
        element_operation(self, data[0]['data'])

    def task_detail_review(self):
        '''
        查看执法任务详情并复查
        :return:
        '''
        data = get_data_by_yaml(get_path() + r'\Data\element_data\site_manage\task\task_detail_review.yaml')
        element_operation(self, data[0]['data'])

    def task_detail_pigeonhole(self):
        '''
        查看执法任务详情并归档
        :return:
        '''
        data = get_data_by_yaml(get_path() + r'\Data\element_data\site_manage\task\task_detail_pigeonhole.yaml')
        element_operation(self, data[0]['data'])

    def task_chargeback(self):
        '''
        任务退单
        :return:
        '''
        data = get_data_by_yaml(get_path() + r'\Data\element_data\site_manage\task\task_chargeback.yaml')
        element_operation(self, data[0]['data'])


if __name__ == '__main__':
    try:
        driver = choose_browser()
        L = LonginPage(driver)
        L.login('kobekq1', 'kobe8888')
        case = Task(driver)
        # case.create_task()
        case.task_list_by_source()
        case.task_list_by_stage()
        case.task_list_by_status()
        case.task_list_sort()
        # case.task_search_error()
        # case.task_search()
        # case.task_detail_accept()
        # case.task_detail_inspect()
        # case.task_detail_review()
        # case.task_detail_pigeonhole()
        # case.task_chargeback()
        time.sleep(5)
        driver.quit()
    except Exception as e:
        print(e)
        driver.quit()

